package v1

import (
	"devops-super/api"
	"devops-super/internal/model/entity"
	"devops-super/internal/model/mymodel"
	"github.com/gogf/gf/v2/frame/g"
)

type GetFirmwarePageLstReq struct {
	g.Meta `method:"get" path:"/firmware/page-list" summary:"分页获取固件列表" tags:"固件"`
	*api.PageLstReq
	Name      string   `json:"name"`
	Version   string   `json:"version"`
	ProductId int64    `json:"productId"`
	TimeRange []string `json:"timeRange"` // 时间范围[开始,结束]
}

type GetFirmwarePageLstRes struct {
	*api.PageLstRes[*mymodel.AppFirmwareResponse]
}

type AddFirmwareReq struct {
	g.Meta    `method:"post" path:"/firmware" summary:"新增固件" tags:"固件"`
	Name      string `v:"required#固件名称不能为空" json:"name"`
	ProductId int64  `v:"required#所属产品不能为空" json:"productId"`
	Version   string `v:"required#固件版本不能为空" json:"version"`
	Part      string `json:"part"`
	Remark    string `json:"remark"`
	FileMd5   string `v:"required#文件md5不能为空" json:"fileMd5"`
	FileUrl   string `v:"required#文件url不能为空" json:"fileUrl"`
	WhereAt   int    `json:"whereAt"`
	AppFileId int64  `json:"appFileId"`
	Image     string `json:"image"`
}

type AddFirmwareRes struct{}

type UptFirmwareReq struct {
	g.Meta    `method:"put" path:"/firmware/{id}" summary:"更新固件" tags:"固件"`
	Id        int    `v:"min:1#固件ID必须" path:"id"`
	Name      string `v:"required#固件名称不能为空" json:"name"`
	ProductId int64  `v:"required#所属产品不能为空" json:"productId"`
	Version   string `v:"required#固件版本不能为空" json:"version"`
	Part      string `json:"part"`
	Remark    string `json:"remark"`
	FileMd5   string `v:"required#文件md5不能为空" json:"fileMd5"`
	FileUrl   string `v:"required#文件url不能为空" json:"fileUrl"`
	WhereAt   int    `json:"whereAt"`
	AppFileId int64  `json:"appFileId"`
	Image     string `json:"image"`
}

type UptFirmwareRes struct{}

type DelFirmwareReq struct {
	g.Meta `method:"delete" path:"/firmware/{id}" summary:"删除固件" tags:"固件"`
	Id     int `v:"min:1#固件ID必须" path:"id"`
}

type DelFirmwareRes struct{}

type GetFirmwareOneReq struct {
	g.Meta `method:"get" path:"/firmware/getOne" summary:"获取一条固件" tags:"固件"`
	Id     int `v:"min:1#固件ID必须" path:"id"`
}

type GetFirmwareOneRes struct {
	Info *entity.AppFirmware `json:"info"`
}

type GetFirmwareOptionsReq struct {
	g.Meta     `method:"get" path:"/firmware/getOptions" summary:"获取固件选项" tags:"固件"`
	FieldKey   string `json:"fieldKey"`   //明确指出key的字段
	FieldLabel string `json:"fieldLabel"` //明确指出label的字段
	ProductId  int64  `json:"productId"`  //可选，按产品筛选
}

type GetFirmwareOptionsRes struct {
	Options []*api.FormOptionsItem `json:"options"`
}
